package com.example.bms.storehouse.service.impl;

import com.example.bms.storehouse.entity.StorehouseEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.utils.PageUtils;
import com.example.common.utils.Query;

import com.example.bms.storehouse.dao.WaterDao;
import com.example.bms.storehouse.entity.WaterEntity;
import com.example.bms.storehouse.service.WaterService;
import org.springframework.util.ObjectUtils;


@Service("waterService")
public class WaterServiceImpl extends ServiceImpl<WaterDao, WaterEntity> implements WaterService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        QueryWrapper<WaterEntity> queryWrapper=new QueryWrapper<WaterEntity>();
        String name =(String) params.get("key");

        if(!ObjectUtils.isEmpty(name)){
            queryWrapper.like("wname",name);
        }

        queryWrapper.orderByDesc("type");

        IPage<WaterEntity> page = this.page(
                new Query<WaterEntity>().getPage(params),
                queryWrapper
        );
        return new PageUtils(page);
    }

}